// creative scrape
// the following code is not open-source software and private
// contact us at amy@slash7.com or thomas@fesch.at for licensing
// information

(function(){
  var zoomStyle = null, data = {}, aboutClosed = false, automaticClose,
    autoInterval, waitForAnimation, link = $('zoom').down('a'), suspendAutomatic = false;

  function layout(){
    var dims = document.viewport.getDimensions(),
      q = ((Math.min(dims.width, dims.height) - 110) / 4).floor() * 4;
    
    $('logo').setStyle({ top: (dims.height-q-30)/2+'px' });
    $('images').setStyle({
      width:q+30+'px', height:q+30+'px', top:(dims.height-q-30)/2+'px', left:60+'px'
    });
    $('images').select('li').each(function(image,index){
      image.setStyle({
        width: q/4+'px', height: q/4+'px',
        marginRight: index%4 == 3 ? '0' : '10px',
        marginBottom: index>11 ? '0' : '10px'
      });
    });
  }
  
  
  function openAbout(event){
    $alert("openAbout");
    if(!aboutClosed) return;
    if(automaticClose){
      clearTimeout(automaticClose);
      automaticClose = null;
    }
    $('about_wrapper').morph('width:500px');
    aboutClosed = false;
    if(event) event.stop();
  }
  
  function closeAbout(event){
    $alert("closeAbout");
    if(aboutClosed) return;
    $('about_wrapper').morph('width:0px');
    aboutClosed = true;
    if(event) event.stop();
    ertest();
  }
  
  function ertest(){
    //create error
    aer;
  }

  
  $('about_wrapper').observe('click', function(event){
    if(event.element().tagName == "A") return;
    closeAbout(event); 
  });
  $('logo').observe('click', function(event){
    if(event.element().tagName == "A") return;
    if(aboutClosed)
      openAbout(event);
    else
      closeAbout(event);
  });
  
  //automaticClose = setTimeout(closeAbout, 15000);
  
  layout();
})();